import {defineStore} from "pinia";
import axios from "axios";
import {nanoid} from "nanoid";
import {reactive} from "vue";

export const useLoveTalkStore = defineStore('loveTalk', () => {
    const loveTalkList = reactive(JSON.parse(localStorage.getItem('loveTalkList')))

    async function getLoveTalk() {
        let {data} = await axios.get('https://api.uomg.com/api/rand.qinghua?format=json')
        let obj = {id: nanoid(), title: data.content}
        loveTalkList.unshift(obj)
    }

    return {loveTalkList, getLoveTalk}
})
